<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QStringListModel Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QStringListModel Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStringListModel class provides a model that supplies
strings to views. <a href="#details">More...</a></p>

<p>Inherits <a href="qabstractlistmodel.html">QAbstractListModel</a>.</p><p>Inherited by <a href="qhelpindexmodel.html">QHelpIndexModel</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstringlistmodel.html#QStringListModel">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#QStringListModel-2">__init__</a></b> (<i>self</i>, QStringList&#160;<i>strings</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QVariant <b><a href="qstringlistmodel.html#data">data</a></b> (<i>self</i>, QModelIndex&#160;<i>index</i>, int&#160;<i>role</i>)</li><li><div class="fn" />Qt.ItemFlags <b><a href="qstringlistmodel.html#flags">flags</a></b> (<i>self</i>, QModelIndex&#160;<i>index</i>)</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#insertRows">insertRows</a></b> (<i>self</i>, int&#160;<i>row</i>, int&#160;<i>count</i>, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#removeRows">removeRows</a></b> (<i>self</i>, int&#160;<i>row</i>, int&#160;<i>count</i>, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />int <b><a href="qstringlistmodel.html#rowCount">rowCount</a></b> (<i>self</i>, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#setData">setData</a></b> (<i>self</i>, QModelIndex&#160;<i>index</i>, QVariant&#160;<i>value</i>, int&#160;<i>role</i>&#160;=&#160;Qt.EditRole)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#setStringList">setStringList</a></b> (<i>self</i>, QStringList&#160;<i>strings</i>)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#sort">sort</a></b> (<i>self</i>, int&#160;<i>column</i>, Qt.SortOrder&#160;<i>order</i>&#160;=&#160;Qt.AscendingOrder)</li><li><div class="fn" />QStringList <b><a href="qstringlistmodel.html#stringList">stringList</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.DropActions <b><a href="qstringlistmodel.html#supportedDropActions">supportedDropActions</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStringListModel class provides a model that supplies
strings to views.</p>
<p>QStringListModel is an editable model that can be used for
simple cases where you need to display a number of strings in a
view widget, such as a <a href="qlistview.html">QListView</a> or a
<a href="qcombobox.html">QComboBox</a>.</p>
<p>The model provides all the standard functions of an editable
model, representing the data in the string list as a model with one
column and a number of rows equal to the number of items in the
list.</p>
<p>Model indexes corresponding to items are obtained with the
<a href="qabstractlistmodel.html#index">index()</a> function, and
item flags are obtained with <a href="qstringlistmodel.html#flags">flags</a>(). Item data is read with
the <a href="qstringlistmodel.html#data">data</a>() function and
written with <a href="qstringlistmodel.html#setData">setData</a>().
The number of rows (and number of items in the string list) can be
found with the <a href="qstringlistmodel.html#rowCount">rowCount</a>() function.</p>
<p>The model can be constructed with an existing string list, or
strings can be set later with the <a href="qstringlistmodel.html#setStringList">setStringList</a>()
convenience function. Strings can also be inserted in the usual way
with the <a href="qstringlistmodel.html#insertRows">insertRows</a>() function, and
removed with <a href="qstringlistmodel.html#removeRows">removeRows</a>(). The contents
of the string list can be retrieved with the <a href="qstringlistmodel.html#stringList">stringList</a>() convenience
function.</p>
<p>An example usage of QStringListModel:</p>
<pre class="cpp">
     <span class="type">QStringListModel</span> <span class="operator">*</span>model <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QStringListModel</span>();
     <span class="type"><a href="qstringlist.html">QStringList</a></span> list;
     list <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"a"</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"b"</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"c"</span>;
     model<span class="operator">-</span><span class="operator">&gt;</span>setStringList(list);
</pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStringListModel" />QStringListModel.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a string list model with the given <i>parent</i>.</p>


<h3 class="fn"><a name="QStringListModel-2" />QStringListModel.__init__ (<i>self</i>, QStringList&#160;<i>strings</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a string list model containing the specified
<i>strings</i> with the given <i>parent</i>.</p>


<h3 class="fn"><a name="data" />QVariant QStringListModel.data (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>, int&#160;<i>role</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#data">QAbstractItemModel.data</a>().</p>
<p>Returns data for the specified <i>role</i>, from the item with
the given <i>index</i>.</p>
<p>If the view requests an invalid index, an invalid variant is
returned.</p>
<p><b>See also</b> <a href="qstringlistmodel.html#setData">setData</a>().</p>


<h3 class="fn"><a name="flags" /><a href="qt-itemflags.html">Qt.ItemFlags</a> QStringListModel.flags (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#flags">QAbstractItemModel.flags</a>().</p>
<p>Returns the flags for the item with the given <i>index</i>.</p>
<p>Valid items are enabled, selectable, editable, drag enabled and
drop enabled.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#flags">QAbstractItemModel.flags</a>().</p>


<h3 class="fn"><a name="insertRows" />bool QStringListModel.insertRows (<i>self</i>, int&#160;<i>row</i>, int&#160;<i>count</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel.insertRows</a>().</p>
<p>Inserts <i>count</i> rows into the model, beginning at the given
<i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used
for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a
null index is specified, indicating that the rows are inserted in
the top level of the model.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel.insertRows</a>().</p>


<h3 class="fn"><a name="removeRows" />bool QStringListModel.removeRows (<i>self</i>, int&#160;<i>row</i>, int&#160;<i>count</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel.removeRows</a>().</p>
<p>Removes <i>count</i> rows from the model, beginning at the given
<i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used
for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a
null index is specified, indicating that the rows are removed in
the top level of the model.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel.removeRows</a>().</p>


<h3 class="fn"><a name="rowCount" />int QStringListModel.rowCount (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel.rowCount</a>().</p>
<p>Returns the number of rows in the model. This value corresponds
to the number of items in the model's internal string list.</p>
<p>The optional <i>parent</i> argument is in most models used to
specify the parent of the rows to be counted. Because this is a
list if a valid parent is specified, the result will always be
0.</p>
<p><b>See also</b> <a href="qstringlistmodel.html#insertRows">insertRows</a>(), <a href="qstringlistmodel.html#removeRows">removeRows</a>(), and <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel.rowCount</a>().</p>


<h3 class="fn"><a name="setData" />bool QStringListModel.setData (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>, QVariant&#160;<i>value</i>, int&#160;<i>role</i>&#160;=&#160;Qt.EditRole)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#setData">QAbstractItemModel.setData</a>().</p>
<p>Sets the data for the specified <i>role</i> in the item with the
given <i>index</i> in the model, to the provided <i>value</i>.</p>
<p>The <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>() signal is
emitted if the item is changed.</p>
<p><b>See also</b> <a href="qt.html#ItemDataRole-enum">Qt.ItemDataRole</a> and <a href="qstringlistmodel.html#data">data</a>().</p>


<h3 class="fn"><a name="setStringList" />QStringListModel.setStringList (<i>self</i>, QStringList&#160;<i>strings</i>)</h3><p>Sets the model's internal string list to <i>strings</i>. The
model will notify any attached views that its underlying data has
changed.</p>
<p><b>See also</b> <a href="qstringlistmodel.html#stringList">stringList</a>() and <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>().</p>


<h3 class="fn"><a name="sort" />QStringListModel.sort (<i>self</i>, int&#160;<i>column</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a>&#160;<i>order</i>&#160;=&#160;Qt.AscendingOrder)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#sort">QAbstractItemModel.sort</a>().</p>


<h3 class="fn"><a name="stringList" />QStringList QStringListModel.stringList (<i>self</i>)</h3><p>Returns the string list used by the model to store data.</p>
<p><b>See also</b> <a href="qstringlistmodel.html#setStringList">setStringList</a>().</p>


<h3 class="fn"><a name="supportedDropActions" /><a href="qt-dropactions.html">Qt.DropActions</a> QStringListModel.supportedDropActions (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#supportedDropActions">QAbstractItemModel.supportedDropActions</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>